package jmine.tec.services.test.services;

import java.math.BigDecimal;
import java.util.List;

import jmine.tec.di.annotation.Injected;
import jmine.tec.di.scope.TypedScope;
import jmine.tec.services.annotations.Execution;
import jmine.tec.services.annotations.Input;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.annotations.WithPreffix;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.ServiceProperties;
import junit.framework.Assert;

@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class CollectionService extends Assert {

    private List<String> stList;

    private BigDecimal val;

    @Input(fieldName = "bla", defaultValue = "bla")
    private String something;
    
    @Input(fieldName = "bla2")
    private Integer bla;
    
    /**
     * @param stList the stList to set
     */
    @WithPreffix(preffix = "nada")
    public final void setStList(List<String> stList) {
        this.stList = stList;
    }

    /**
     */
    @Execution
    public void execute(@Input(fieldName = "bla", defaultValue = "0.11") BigDecimal v, @Injected TypedScope currentScope,
            @Injected ServiceProperties props) {
        assertNotNull("lista nao deve ser null", this.stList);
        assertTrue("lista deve estar vazia", this.stList.isEmpty());
        assertEquals("input com default value", new BigDecimal("0.11"), this.val);
        assertEquals("parametro com default value", new BigDecimal("0.11"), v);
        assertNotNull(currentScope);
        assertNotNull(props);
        assertNotNull(something);
        assertEquals("bla", something);
        assertEquals(Integer.valueOf(1), bla);
    }

    /**
     * @param val the val to set
     */
    @Input(required = false, defaultValue = "0.11")
    public final void setVal(BigDecimal val) {
        this.val = val;
    }

}
